<?php
class Customer_TripController extends Zend_Controller_Action
{
	public function indexAction()
	{
		
	}
	
	public function listAction()
	{		
		// get params
		$from = $this->_request->getParam('from', 'Hồ Chí Minh');
		$to = $this->_request->getParam('to', 'Hà Nội');
		$date = $this->_getParam('date', '01-08-2011');
		
		// convert dd-MM-y to y-MM-dd to operate in MySQL
		$dateFormat = new Zend_Date($date, 'dd-MM-y');
		$date = $dateFormat->toString('y-MM-dd');

		// create paginator
		$tripModel = new Customer_Model_Trip();
		$tripArray = $tripModel->getTripArray($from, $to, $date);		
		if(count($tripArray) > 0)
		{		
			$paginator = Zend_Paginator::factory($tripArray);
			$paginator->setItemCountPerPage(5);
			$page = $this->_request->getParam('page', 1);
			$paginator->setCurrentPageNumber($page);
			
			$this->view->paginator = $paginator;
			$this->view->column_count = count($tripArray[0]);
		}
	}
	
	
}